package com.PAT.UnSatisfying;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * 3 5
 * 3 4 2 a c
 * 2 5 1 b
 * 5 3 2 b c
 * 1 5 4 a b d e
 * 3 6 2 c d
 * (2 a c) (1 b) (2 b c) (4 a b d e) (2 c d)
 * (2 a c) (1 b) (2 a b) (4 a b d e) (2 c d)
 * (2 b d) (1 e) (2 b c) (4 a b c d) (2 c e)
 * @Author: zjz
 * @Date: 2022/01/06/22:20
 * @Description:
 * @Target: 差6
 */
public class 选择题 {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s1 = in.nextLine();
        String[] s = s1.split(" ");
        int M =Integer.valueOf(s[0]); // 人数
        int N =Integer.valueOf(s[1]); // 对的答案
        int min = Integer.MAX_VALUE;  // 最小的正确次数
        String[] MArray = new String[M]; // 数组，记录人数
        String[] NArray = new String[N]; // 数组，记录对的答案
        int[] count = new int[N];  // 记录对的次数
        int[] countScore = new int[M]; // 记录成绩

        for (int i = 0; i < N; i++) {
            NArray[i] = in.nextLine();
        }

        for (int i = 0; i < M; i++) {
            MArray[i] = in.nextLine();
        }




        for (int i = 0; i < M; i++) {
            int index = 0;
            String[] split = MArray[i].split("\\) \\(");
            while (index<split.length){
                if (index==0){
                    if ((split[index].substring(1,split[index].length())).equals(NArray[index].substring(4,NArray[index].length()))){
                        countScore[i]+=(NArray[index].charAt(0)-'0');
                        count[index]++;
                    }
                }else if (index== split.length-1){
                    if ((split[index].substring(0,split[index].length()-1)).equals(NArray[index].substring(4,NArray[index].length()))){
                        countScore[i]+=(NArray[index].charAt(0)-'0');
                        count[index]++;
                    }
                }else {
                    if (split[index].equals(NArray[index].substring(4,NArray[index].length()))){
                        countScore[i]+=(NArray[index].charAt(0)-'0');
                        count[index]++;
                    }
                }


                index++;
            }

        }

        for (int i : countScore) {
            System.out.println(i);
        }

        for (int i : count) {
            min = i>min?min:i;
        }


        if (min==M){
            System.out.println("Too simple");
        }else {
            System.out.print((M-min));  // min为我找到的最小正确次数，M为学生人数
            for (int i = 0; i < count.length; i++) {
                if (count[i]==min){
                    System.out.print(" "+(i+1));
                }
            }
        }


    }
}
